package cn.iocoder.yudao.module.call.convert.location;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.call.controller.admin.agent.vo.AgentRespVO;
import cn.iocoder.yudao.module.call.controller.admin.location.vo.LocationRespVO;
import cn.iocoder.yudao.module.call.dal.dataobject.location.LocationDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Map;

@Mapper
public interface LocationConverter {
    LocationConverter INSTANCE = Mappers.getMapper(LocationConverter.class);

    default LocationRespVO convert(LocationDO data, Map<Long, Long> countMap) {

        LocationRespVO resp = BeanUtils.toBean(data, LocationRespVO.class);
        // 负责人
        MapUtils.findAndThen(countMap, data.getId(), resp::setCount);

        return resp;
    }


    default PageResult<LocationRespVO> convert0(PageResult<LocationDO> pageResult, Map<Long, Long> countMap) {
        List<LocationRespVO> dataList = CollectionUtils.convertList(pageResult.getList(), caseDO -> convert(caseDO, countMap));
        PageResult<LocationRespVO> newResult = new PageResult<LocationRespVO>();
        newResult.setList(dataList);
        newResult.setTotal(pageResult.getTotal());
        return newResult;
    }


}
